package com.maybach.core.security;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;


/**
 * Created by houenxun on 16/1/22.
 */
public class AdminUserUtil {

    private static final ThreadLocal<AdminUser> userHolder = new ThreadLocal<AdminUser>();

    public static AdminUser getUser() {
        AdminUser user = userHolder.get();
        if (null != user) {
            return user;
        }
        Subject subject = SecurityUtils.getSubject();
        user = new AdminUser(subject);
        userHolder.set(user);
        return user;
    }

    public static void clear() {
        userHolder.remove();
    }


}
